
<?php
$sysApps = new sysApps();
$sysApps->DBconnect();
?>

<div class="page-info">
	<div class="pageTitle">Commission List</div>
    <div class="user_email bgGrey">Email</div>
    <div class="user_MGM_id bgGrey">MGM ID</div>
    <div class="user_start_date bgGrey">Commission</div>
    <div class="clearFloat"></div>
    
    
    <?php
		$user_id = $_SESSION['login_id'];
		$current_month = date("n");
		$current_year = date("Y");
		$sql = "SELECT mu.fullname, mu.user_MGM_id, uc.total_commission
				FROM mgm_users mu
				LEFT JOIN user_commission uc
				ON mu.id = uc.id 
				AND uc.month = '".$current_month."' 
				AND uc.year = '".$current_year."'
				WHERE mu.payment_status = '1'
				 
				";
		$query = mysql_query($sql);
		while ($row = mysql_fetch_array($query)) {
			//echo '<p>'.$row['id'].'+'.$row['email'].'+'.$row['user_MGM_id'].'+'.$row['fullname'].'+'.$row['start_month'].'+'.$row['end_month'].'</p>';
			echo '<div class="user_email">'.$row['fullname'].'</div>';
			echo '<div class="user_MGM_id">'.$row['user_MGM_id'].'</div>';
			if($row['total_commission'] === NULL)
			{
				echo '<div class="user_start_date">RM 0.00</div>';
			}
			else
			{
				echo '<div class="user_start_date">RM '.number_format((float)$row['total_commission'], 2, '.', '').'</div>';
			}
			
			echo '<div class="clearFloat"></div>';
		}
	?>
</div>
<div class="smallButton">UPDATE</div>
<script>

$(document).ready(function(){
	$('.frm_checklogin').hide();
	
	$('.smallButton').click(function(){
		$.post("<?php echo $sysApps->BASEurl();?>/members/func/updateIncome.php", "", function(response){
			//alert(response);
			location.reload();
		});
	});
});

</script>